package com.io.example.demoparent.convert;

import com.io.example.demoparent.bo.Person;
import com.io.example.demoparent.dto.PersonDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;


/**
 * @program: demo-project
 * @ClassName PersonMapper
 * @description:
 * @author: 宠儿
 * @create: 2024−09-06 00:04
 * @Version 1.0
 **/
@Mapper
public interface PersonMapper {

    PersonMapper INSTANCT = Mappers.getMapper(PersonMapper.class);


    @Mappings({
            @Mapping(target = "personName", source = "name"),
            @Mapping(target = "id", ignore = true),// 忽略id，不进行映射
            @Mapping(target = "code", source = "enumCode.code"),
            @Mapping(source = "birthday", target = "birthday", dateFormat = "yyyy-MM-dd HH:mm:ss")
    })
    PersonDto toDTO(Person person);
}
